import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
	state: {
		token: '',
		username: ""
	},

	mutations: {
		set_token(state, token) {
			state.token = token
			sessionStorage.setItem("token", token); 
		},
		set_username(state, username) {
			state.username = username
			sessionStorage.setItem("username", username); 

		},
		del_token(state) {
			state.token = ''
			state.username = ''
			sessionStorage.removeItem('token')
			sessionStorage.removeItem('username')
		}
	}
})

export default store
